package com.masterclient.app.modules.shop.adapter;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.masterclient.app.R;
import com.masterclient.app.base.MainViewHolder;

/**
 * @auther hjian
 * @date 2020/5/11.
 */
public class DividingLineLayoutAdapter extends DelegateAdapter.Adapter<MainViewHolder> {

    private Activity mContext;
    private LayoutHelper mLayoutHelper;
    private VirtualLayoutManager.LayoutParams mLayoutParams;
    private int count = 0;
    private int divideHeight = 0;

    public DividingLineLayoutAdapter(Activity mContext, LayoutHelper mLayoutHelper, VirtualLayoutManager.LayoutParams mLayoutParams, int count, int divideHeight) {
        this.mContext = mContext;
        this.mLayoutHelper = mLayoutHelper;
        this.mLayoutParams = mLayoutParams;
        this.count = count;
        this.divideHeight = divideHeight;
    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return mLayoutHelper;
    }

    @NonNull
    @Override
    public MainViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MainViewHolder(LayoutInflater.from(mContext).inflate(R.layout.layout_line,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull MainViewHolder holder, int position) {
        FrameLayout frameLayout = holder.itemView.findViewById(R.id.line_root);
        frameLayout.getLayoutParams().width = ScreenUtils.getScreenWidth();
        frameLayout.getLayoutParams().height = divideHeight;
    }

    @Override
    public int getItemCount() {
        return count;
    }

    @Override
    public int getItemViewType(int position) {
        return 7;
    }
}
